package com.junwell.quartz;

import com.junwell.mapper.WaysMapper;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;
import redis.clients.jedis.GeoCoordinate;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

import java.util.List;

/**
 * @author Junwell
 * @date 2023/3/4 17:07
 */

public class RedisJob extends QuartzJobBean {

    @Autowired
    private JedisPool jedisPool;

    @Autowired
    private WaysMapper waysMapper;

    @Override
    protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
        System.out.println(jedisPool);
        Jedis jedis = jedisPool.getResource();
        List<GeoCoordinate> list = jedis.geopos("station", "李载", "张三", "李四", "王五", "赵六", "赵虎", "张龙");
        System.out.println("各线路司机定位"+list);
        System.out.println(waysMapper.wayOne(list.get(0) + ""));
        System.out.println(waysMapper.wayTwo(list.get(1) + ""));
        System.out.println(waysMapper.wayThree(list.get(2) + ""));
        System.out.println(waysMapper.wayFour(list.get(3) + ""));
        System.out.println(waysMapper.wayFive(list.get(4) + ""));
        System.out.println(waysMapper.waySix(list.get(5) + ""));
        System.out.println(waysMapper.waySeven(list.get(6) + ""));

        jedis.close();
        /*SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Date date=new Date();
        System.out.println("当前时间:"+simpleDateFormat.format(date));*/
    }
}
